package mycoffee.order.model;

public class Discount extends Root {
    /**
	 * 
	 */
    private static final long serialVersionUID = 1L;
    private String mName;
    private int mPercent;
    private double mMoney;

    public Discount() {
        super();
    }

    /**
     * Constructor with parameters
     * 
     * @param name
     * @param percent
     */

    public Discount(String name, int percent) {
        this.mName = name;
        this.mPercent = percent;
    }

    public Discount(Discount discount) {
        this.mName = discount.getName();
        this.mPercent = discount.getPercent();
        this.mMoney = discount.getMoney();
    }

    public String getName() {
        return mName;
    }

    public void setName(String name) {
        mName = name;
    }

    public int getPercent() {
        return mPercent;
    }

    public void setPercent(int percent) {
        mPercent = percent;
    }

    /**
     * @return the money
     */
    public double getMoney() {
        return mMoney;
    }

    /**
     * @param money
     *            the money to set
     */
    public void setMoney(double money) {
        mMoney = money;
    }

    public double getTotalDiscountMoney(double totalMoney) {
        double result = 0;
        if (mPercent > 0) {
            result = totalMoney * mPercent / 100;
        } else {
            result = mMoney;
        }
        return result;

    }
}
